﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq.Expressions;
using System.Threading;

namespace CSharpStudy
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                var t1 = new TestClass();
                var t2 = TestMethod1(t1);

                Console.WriteLine(t1.Value);
                Console.WriteLine(t2);
            }
            {
                var t1 = new TestClass();
                var t2 = TestMethod2(ref t1);

                Console.WriteLine(t1);
                Console.WriteLine(t2);
            }
        }

        private static TestClass TestMethod1(TestClass test)
        {
            test.Value = 10;
            test = null;
            return test;
        }

        private static TestClass TestMethod2(ref TestClass test)
        {
            test.Value = 10;
            test = null;
            return test;
        }
    }

    internal class TestClass
    {
        public int Value { get; set; }
    }
}
